package api

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

const SessionKey = "session_id"

type SessionAuth struct {
}

func (s *SessionAuth) Auth(ctx *gin.Context) {
	sessionID := ctx.GetHeader(SessionKey)
	if sessionID == "" {
		ctx.AbortWithStatusJSON(http.StatusForbidden, "session is null")
	}
	fmt.Printf("session_id=%v\n", sessionID)
	ctx.Next() // 是整个调用链继续执行
	fmt.Println("Auth end======")
}
